@use 'sass:map';

@use './shared' as *;
@use './design' as *;

$divider: () !default;
$divider: map.merge(
  (
    b-color: get-css-var('border-color-light-2'),
    border: get-css-var('border-shape') get-css-var('divider-b-color'),
    v-margin: 24px,
    v-margin-text: 14px,
    h-margin: 8px,
    text-color: get-css-var('content-color-base'),
    text-v-padding: 0,
    text-h-padding: 14px,
    text-size-primary: get-css-var('font-size-primary')
  ),
  $divider
);

.#{$namespace}-divider {
  &-vars {
    @include define-preset-values('divider', $divider);
  }

  @include basis;
  @include inherit-color;

  display: flex;
  padding: 0;
  border-top: get-css-var('divider-border');

  &--horizontal {
    width: 100%;
    margin: get-css-var('divider-v-margin') 0;
    clear: both;
  }

  &--vertical {
    position: relative;
    display: inline-block;
    height: 14px;
    margin: 0 get-css-var('divider-h-margin');
    vertical-align: middle;
    border-inline-start: get-css-var('divider-border');
    border-top: 0;
  }

  &--with-text {
    margin: get-css-var('divider-v-margin-text') 0;
    text-align: center;
    white-space: nowrap;
    border-top: 0;

    &::before,
    &::after {
      position: relative;
      top: 50%;
      width: 50%;
      content: '';
      border-top: get-css-var('divider-border');
      transform: translateY(50%);
    }
  }

  &--with-text-left {
    &::before {
      width: 5%;
    }

    &::after {
      width: 95%;
    }
  }

  &--with-text-right {
    &::before {
      width: 95%;
    }

    &::after {
      width: 5%;
    }
  }

  &--dashed {
    &,
    &::before,
    &::after {
      border-top-style: dashed;
    }
  }

  &__text {
    display: inline-block;
    padding: get-css-var('divider-text-v-padding') get-css-var('divider-text-h-padding');
    color: get-css-var('divider-text-color');
    text-align: center;
    white-space: nowrap;
  }

  &--primary &__text {
    font-size: get-css-var('divider-text-size-primary');
    font-weight: 500;
  }
}
